// char* str = "hello world\n";
// int count = 0;

#include <stdio.h>
// int in_a = 1, in_b = 2, out_sum;

int main(int argc, char const *argv[])
{
    // 基本内联汇编

    // asm ("pusha; \
    //     movl $4, %eax; \
    //     movl $1, %ebx; \
    //     movl str, %ecx; \
    //     movl $12, %edx; \
    //     int $0x80; \
    //     mov %eax, count; \
    //     popa");    

    // asm ("  pusha;  \
    //         movl in_a, %eax;    \
    //         movl in_b, %ebx;    \
    //         addl %ebx, %eax;    \
    //         movl %eax, out_sum; \
    //         popa;");
    // printf("sum is %d\n", out_sum);
  
    //扩展内联汇编
    // int in_a = 1, in_b = 2, out_sum;
    // // asm("addl %%ebx, %%eax" : "=a"(out_sum) : "a"(in_a), "b"(in_b));
    // // printf("sum is %d\n", out_sum);
    // printf("in_b is %d\n", in_b);
    // asm("movb %b0, %1;" : : "a"(in_a), "m"(in_b));
    // printf("in_b now is %d\n", in_b);

    //汇编修饰符
    int ret_cnt = 0, test = 0;
    char* fmt = "hello, world\n";
    asm("   pushl %1;               \
            call printf;            \
            movl $6, %2"            \
        :   "=&a"(ret_cnt)           \
        :   "m"(fmt), "r"(test));
    printf("the number of bytes writen is %d\n", ret_cnt);
    return 0;
}
